using System;
using Core;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SolarWinds.Layouts;
using SolarWinds.Transitions;
using SolarWinds.Widgets;

namespace SolarWinds.Screens
{
    public class PauseScreen : Screen
    {
        readonly WidgetManager mWidgetManager;

        public PauseScreen(Game game)
            : base(game)
        {
            BlocksUpdate = true;
            BlocksDraw = false;
            ColorReduction = 0.5f;

            mWidgetManager = new WidgetManager(game);
            Components.Add(mWidgetManager);
        }

        public override void Initialize()
        {
            base.Initialize();

            #region Widgets

            Viewport vp = GraphicsDevice.Viewport;

            var window = new Window(Game)
                             {
                                 Position = new Point(vp.Width/2 - 100, vp.Height/2 - 35),
                                 Caption = "Pause",
                                 Width = 200,
                                 Height = 70,
                                 Resizeable = false,
                                 Moveable = false,
                                 Layout = new BoxLayout(Direction.LeftToRight)
                             };
            mWidgetManager.AddChild(window);

            var continueButton = new PushButton(Game)
                                     {
                                         Position = new Point(20, 20),
                                         Width = 100,
                                         Height = 16,
                                         Caption = "Resume"
                                     };
            continueButton.Clicked += ContinueButtonClicked;
            window.AddChild(continueButton);

            #endregion
        }

        void ContinueButtonClicked(object sender, EventArgs e)
        {
            var t = new SlideTransition(Game) {Direction = Direction.RightToLeft};

            ScreenManager.PopScreen(t, true);
        }
    }
}